<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>添加新类别 <small>认真填写，谨慎操作！</small></h2>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <br>
                <form id="addCategoryForm" th:action="@{/category/add}" class="form-horizontal form-label-left"
                      onsubmit="return false">
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="username">类别名称<span
                                class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="text" id="username" name="name" required="required"
                                   class="form-control col-md-7 col-xs-12">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">所属板块<span
                                class="required">*</span></label>
                        <div class="col-md-3 col-sm-3 col-xs-12">
                            <select class="form-control" name="plateId" >
                                <option th:each="p,plate:${plates}" th:value="${p.id}" th:text="${p.getName()}"></option>
                            </select>
                        </div>
                    </div>
                    <div class="ln_solid"></div>
                    <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                            <button class="btn btn-primary" type="button" onclick="$c.dialogClose(categoryAddDialog)">取消
                            </button>
                            <button type="button" id="addCategoryBut" class="btn btn-success">提交</button>
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $('#addCategoryBut').on('click', function () {
        $c.ajax({
            form: $('#addCategoryForm'),
            success: function (d) {
                if (d.code == 200) {
                    $c.dialogClose(categoryAddDialog);
                    $c.notify(d.msg);
                    $('#categoryTable').DataTable().ajax.reload();
                } else {
                    $c.notify(d.msg);
                }
            }
        })
    })
</script>
</html>
